//index.js
//获取应用实例
var app = getApp();
var ImageURL = app.globalData1.ImageURL;
var hostURL = app.globalData1.hostURL;
Page({
  data: {
    navList: [],
    goodsList: [],
    id: "",
    // currentCategory: {},
    scrollLeft: 0,
    scrollTop: 0,
    scrollHeight: 0,
    page: 1,
    size: 10000,

    curNav: 1,
    curIndex: 0,
    sourceId:'',
  

  },


  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    var that = this


    if (options.id) {
      that.setData({
        id: parseInt(options.id)
      });
    }
    console.log("id" + parseInt(options.id))
    //获取容器高度。
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          scrollHeight: res.windowHeight
        });
      }
    });
    wx.request({
      url: hostURL + 'sharedplatform-web/source/findSourceBySort.action',
      method: 'GET',
      data: 
      {
        sortId: that.data.id,
      },
      header: {
        'Accept': 'application/json'
      },
      success: function (res) {
        console.log("list请求成功")
        that.setData({
          navList: res.data.categorySourceVOList,
          currentCategory: res.data.categorySourceVOList,
          goodsList: res.data.categorySourceVOList
        });
        
      }


    })

  },

  //事件处理函数  
  switchTab: function (e) {
    // 获取item项的id，和数组的下标值  
    var that=this
    let id = e.currentTarget.dataset.id,

      index = parseInt(e.target.dataset.index);
    // 把点击到的某一项，设为当前index  
    that.setData({
      curNav: id,
      curIndex: index
    })  
    console.log("id" + id)
  },


  togoods: function (e) {
    console.log("dianji:"+e)
    var Id = e.currentTarget.dataset.id
    console.log(e.target.dataset.id)
    console.log("ID"+Id)
    wx.navigateTo({
      url: "/pages/goods/goods?sourceId=" + Id,
    })

  },
})